package kr.hkit.androidcomplete01.ch07;

import kr.hkit.androidcomplete01.ch07.Primitive1.MyView;
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Bundle;
import android.view.View;

public class Primitive2 extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(new MyView(this));
	}

	class MyView extends View {

		private Paint paint;
		private RectF rect;
		private float[] pts = {10, 210, 50, 250, 50, 250, 110, 220};
		private float[] pts2 = {20, 210, 50, 240, 100, 220};

		public MyView(Context context) {
			super(context);
			paint = new Paint(Paint.ANTI_ALIAS_FLAG);
			rect = new RectF(10, 10, 100, 100);
		}

		@Override
		protected void onDraw(Canvas canvas) {
			paint.setColor(Color.LTGRAY);
			canvas.drawPaint(paint);
			
			paint.setColor(Color.RED);
			canvas.drawRoundRect(rect, 10, 10, paint);
			
			rect.set(110, 10, 150, 100);
			canvas.drawOval(rect, paint);
			
			paint.setColor(Color.MAGENTA);
			
			rect.set(10, 110, 100, 200);
			canvas.drawArc(rect, 10, 150, false, paint);
			
			rect.set(110, 110, 200, 200);
			canvas.drawArc(rect, 10, 150, true, paint);
			
			paint.setColor(Color.BLUE);
			canvas.drawLines(pts, paint);
			
			paint.setColor(Color.BLACK);
			canvas.drawPoints(pts2, paint);
		}
	}
}
